home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / utils / bibtools / makebib (.txt) < prev    next >
LaTeX Document  |  1992-09-03  |  2KB  |  63 lines

  1. #!/bin/csh -f
  2. # makebib - make a bib file that has the given citations
  3. # usage: 
  4. #    makebib [-n | -d] file.bib... [citekey]...
  5. # Where -n means "no comment", ie, don't include any "comment" fields.
  6. # And -d means "dfk", ie, add attribution to dfk to all comment fields.
  7. # Output is to subset.bib. If citekey is not given, then all refs in
  8. # the bibfile are included.
  9. onintr cleanup
  10. if ($#argv < 1) then
  11.        echo 'usage: makebib [-n|-d] file.bib... [citekey]...'
  12.        exit 1
  13. endif
  14. if ("$1" == "-n") then
  15.        set bst=subset-nocomment
  16.        shift
  17.        if ("$1" == "-d") then
  18.               set bst=subset-dfk
  19.               shift
  20.        else
  21.               set bst=subset
  22.        endif
  23. endif
  24. if ($#argv < 1) then
  25.        echo 'usage: makebib [-n|-d] file.bib... [citekey]...'
  26.        exit 1
  27. endif
  28. set files = $1:r
  29. shift
  30. while ($1:e == "bib")
  31.        set files=($files,$1:r)
  32.        shift
  33. echo creating subset.tex for $files
  34. cat > subset.tex <<EOF
  35. \documentstyle{article}
  36. \begin{document}
  37. if ($#argv > 0) then
  38.        foreach f ($*)
  39.           echo "\nocite{$f}" >> subset.tex
  40.        end
  41.        echo "\nocite{*}" >> subset.tex
  42. endif
  43. cat >> subset.tex <<EOF
  44. \bibliographystyle{$bst}
  45. \bibliography{$files}
  46. \end{document}
  47. rm -f subset.{aux,log,dvi,bbl,blg}
  48. echo latex subset.tex
  49. latex subset.tex
  50. echo bibtex subset
  51. bibtex subset
  52. sed > subset.bib \
  53.    -e 's/\\ie/i.e./g' \
  54.    -e 's/\\eg/e.g./g' \
  55.    -e 's/\\etc/{\\em etc.}/g' \
  56.    -e 's/\\vs/{\\em vs.}/g' \
  57.    -e 's/\\usec/{{$\\mu$}sec}/g' \
  58.   subset.bbl
  59. echo ""
  60. echo output is in subset.bib
  61. cleanup:
  62. rm -f subset.{tex,aux,log,dvi,bbl,blg}
  63.